package com.happysearch.service;

import java.util.Collections;
import java.util.Set;

import org.nlp.vec.VectorModel;

public class SearchWordService {
	private final static String modelFilePath = "F:/BaiduDownload/data/resultbig.mod";
	private static SearchWordService sws;
	private VectorModel vm;

	private SearchWordService() {
		vm = VectorModel.loadFromFile(modelFilePath);
		System.out.println("init vm");
	}
	public static SearchWordService getInstance(){
		if (sws == null) {
			sws = new SearchWordService();
		}
		return sws;
	}
	public 	Set<VectorModel.WordScore> getSimlar(String word){
		Set<VectorModel.WordScore> result = Collections.emptySet();
		result = vm.similar(word);
		for (VectorModel.WordScore we : result) {
			System.out.println(we.name + " :\t" + we.score);
		}
		return result;
	}

}
